package net.lab1024.sa.admin.module.business.devicesAlarmList.controller;

import net.lab1024.sa.admin.module.business.devicesAlarmList.domain.form.DevicesAlarmListAddForm;
import net.lab1024.sa.admin.module.business.devicesAlarmList.domain.form.DevicesAlarmListQueryForm;
import net.lab1024.sa.admin.module.business.devicesAlarmList.domain.form.DevicesAlarmListUpdateForm;
import net.lab1024.sa.admin.module.business.devicesAlarmList.domain.vo.DevicesAlarmListVO;
import net.lab1024.sa.admin.module.business.devicesAlarmList.service.DevicesAlarmListService;
import net.lab1024.sa.base.common.annoation.NoNeedLogin;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 实时告警列表 Controller
 *
 * @Author 1
 * @Date 2025-07-14 09:31:27
 * @Copyright 1
 */

@RestController
@Tag(name = "实时告警列表")
public class DevicesAlarmListController {

    @Resource
    private DevicesAlarmListService devicesAlarmListService;

    @NoNeedLogin
    @Operation(summary = "分页查询 @author 1")
    @PostMapping("/devicesAlarmList/queryPage")
    @SaCheckPermission("devicesAlarmList:query")
    public ResponseDTO<PageResult<DevicesAlarmListVO>> queryPage(@RequestBody @Valid DevicesAlarmListQueryForm queryForm) {
        return ResponseDTO.ok(devicesAlarmListService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author 1")
    @PostMapping("/devicesAlarmList/add")
    @SaCheckPermission("devicesAlarmList:add")
    public ResponseDTO<String> add(@RequestBody @Valid DevicesAlarmListAddForm addForm) {
        return devicesAlarmListService.add(addForm);
    }

    @Operation(summary = "更新 @author 1")
    @PostMapping("/devicesAlarmList/update")
    @SaCheckPermission("devicesAlarmList:update")
    public ResponseDTO<String> update(@RequestBody @Valid DevicesAlarmListUpdateForm updateForm) {
        return devicesAlarmListService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author 1")
    @PostMapping("/devicesAlarmList/batchDelete")
    @SaCheckPermission("devicesAlarmList:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return devicesAlarmListService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author 1")
    @GetMapping("/devicesAlarmList/delete/{id}")
    @SaCheckPermission("devicesAlarmList:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Integer id) {
        return devicesAlarmListService.delete(id);
    }
}
